package com.ruoyi.system.mapper.evaluation;

import com.ruoyi.system.domain.evaluation.Complaint;
import com.ruoyi.system.domain.evaluation.ComplaintandStore;
import com.ruoyi.system.domain.evaluation.StoreLocation;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ComplaintMapper {
    @Select("select * from ry.complaint")
    List<Complaint> selectComplaint();
    @Select("select c.id,img,c.store_id,content,c.name,department,tel,time,s.name as 'storeName',l.name as 'locationName' from ry.complaint c left join ry.store s on c.store_id=s.id left join ry.location l on l.id = s.location_id order by time desc")
    List<ComplaintandStore> selectComplaintandStore();
    @Select("<script>" +
            "select c.id,img,c.store_id,content,c.name,department,tel,time,s.name as 'storeName',l.name as 'locationName' from ry.complaint c left join ry.store s on c.store_id=s.id left join ry.location l on l.id = s.location_id where c.id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>"+
            " #{id}" +
            "</foreach> order by time desc" +
            "</script>")
    List<ComplaintandStore> selectComplaintByIds(Long[] ids);
    //删除投诉
    @Delete("<script>" +
            "delete from ry.complaint where id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    int deleteComplaint(Long[] ids);
    @Select("select c.id,img,c.store_id,content,c.name,department,tel,time,s.name as 'storeName',l.name as 'locationName' from ry.complaint c left join ry.store s on c.store_id=s.id left join ry.location l on l.id = s.location_id where s.location_id=#{location_id} order by time desc")
    List<ComplaintandStore> selectComplaintByLocation_id(String location_id);
    @Select("select c.id,img,c.store_id,content,c.name,department,tel,time,s.name as 'storeName',l.name as 'locationName' from ry.complaint c left join ry.store s on c.store_id=s.id left join ry.location l on l.id = s.location_id where s.name=#{storeName} order by time desc")
    List<ComplaintandStore> selectStoreByStoreName(String storeName);

}